import fetch from '@/utils/fetch'
// 论坛分页列表
export function getTopicList(jsonData) {
  const { page, size, data } = jsonData
  return fetch({
    url: `front/topic/page?page=${page}&size=${size}`,
    method: 'post',
    data
  })
}
// 论坛详情
export function findTopicById(id) {
  return fetch({
    url: `front/topic/${id}`,
    method: 'get'
  })
}

// 创建论坛
export function createTopic(data) {
  return fetch({
    url: `customer/topic/create`,
    method: 'post',
    data
  })
}

// 更新论坛
export function updateTopic(data) {
  return fetch({
    url: `customer/topic/update`,
    method: 'post',
    data
  })
}

// 上传文件
export function updateFileByTopic(id, data) {
  return fetch({
    url: `customer/topic/file/upload/${id}?type=image&fileType=topic`,
    method: 'post',
    data
  })
}

// 上传文件
export function uploadFile(data) {
  return fetch({
    url: `/upload/`,
    method: 'post',
    data
  })
}

// 收藏
export function favouriteTopic(data) {
  return fetch({
    url: 'customer/topic/favourite/click',
    method: 'post',
    data
  })
}

// 创建评论
export function createComment(data) {
  return fetch({
    url: 'customer/topic/comment/create',
    method: 'post',
    data
  })
}

// 喜欢
export function likeTopic(data) {
  return fetch({
    url: 'customer/topic/like/click',
    method: 'post',
    data
  })
}

// 评论回复
export function commentlike(data) {
  return fetch({
    url: 'customer/topic/commentlike/create',
    method: 'post',
    data
  })
}

// 获取用户点赞收藏数量
export function getTopicCount() {
  return fetch({
    url: 'front/topic/getCount',
    method: 'get'
  })
}

// 获取附件地址
export function getFilePath() {
  return fetch({
    url: '/filePath',
    method: 'get'
  })
}

// 删除评论
export function deleteTopicCount(id) {
  return fetch({
    url: 'front/topic/delete/' + id,
    method: 'get'
  })
}
// 删除评论回复
export function deleteReplyTopicCount(id) {
  return fetch({
    url: 'front/topic/deleteReply/' + id,
    method: 'get'
  })
}
